<template>
	<view>
		<view class="app-logo">
			<u--image src="/static/logo.png" width="140rpx" height="140rpx" mode="cover"></u--image>
			<text class="app-title">积分管理</text>
		</view>
	</view>
</template>

<script>
	import {loginByCode} from '@/api/home.js'
	import {mapActions} from 'vuex';
	import Vue from 'vue';
	export default {
		onLoad() {
			const that = this;
			uni.login({
				success(e) {
					const {code} = e;
					loginByCode(code).then(res => {
						const {code, result, success} = res;
						uni.clearStorageSync();
						if(code === 200 && success) {
							const {userInfo, token} = result;
							that.setUserInfo({
								userInfo,
								token
							});
						} else {
							that.setUserInfo({userInfo: {}});
						}
						setTimeout(() => {
							uni.switchTab({
								url: '/pages/index/index'
							})
						}, 500)
					})
				}
			})
		},
		methods: {
			...mapActions(['setUserInfo']),
		}
	}
</script>

<style lang="scss" scoped>
	.app-logo {
		position: fixed;
		bottom: 160rpx;
		left: 50%;
		transform: translateX(-50%);
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		.app-title {
			padding-top: 12rpx;
			color: #333;
			font-size: 32rpx;
			font-weight: bold;
			letter-spacing: 2rpx;
		}
	}
</style>